﻿// JScript 文件

//open a new window
function el(id) {
    return document.getElementById(id);
}
function en(name) {
    return document.getElementsByName(name);
}

function OpenNewWindow(url) {
    window.open(url);
}

function WindowOpen(url) {
    
    newwindow = window.open("", "newwindow", "scrollbars")
    if (document.all) {
        newwindow.moveTo(0, 0);
        newwindow.resizeTo(screen.width, screen.height);
    }
    newwindow.location = url;
}
function WindowOpenName(url, name) {
    window.open(url, name);
    return false;
}

function ShowDialog(url, iWidth, iHeight) {
    //  var iWidth=800; //窗口宽度
    // var iHeight=400;//窗口高度
    var iTop = (window.screen.height - iHeight) / 2;
    var iLeft = (window.screen.width - iWidth) / 2;
    window.showModalDialog(url, window, "dialogHeight: " + iHeight + "px; dialogWidth: " + iWidth + "px;dialogTop: " + iTop + "; dialogLeft: " + iLeft + "; resizable: no; status: no;scroll:yes");
}

function ShowOpen(url, iWidth, iHeight) {
    //  var iWidth=800; //窗口宽度
    // var iHeight=400;//窗口高度
    var iTop = (window.screen.height - iHeight) / 2;
    var iLeft = (window.screen.width - iWidth) / 2;
    window.open(url, "newwindow", "height=" + iHeight + ", width=" + iWidth + ", toolbar= no, menubar=no, scrollbars=no, resizable=no, location=no, status=no,top=" + iTop + ",left=" + iLeft + "")

}
//open a float div=======================================================================================
function OpenDiv(elementID) {
    var obj = document.getElementById(elementID);
    obj.style.display = "block";
    obj.style.left = document.body.scrollLeft + event.x; //-obj.style.width;
    obj.style.top = document.body.scrollTop + event.clientY - event.offsetY; //-235;

}

function OpenDivDirectly(elementID) {
    var obj = document.getElementById(elementID);
    obj.style.display = "block";
}

//========================================================================================================
//close a float div
function CloseDiv(elementID) {
    document.getElementById(elementID).style.display = "none";
}

//Add new question----question type switch helper==========================================================
/* var QuesyionTypeArray=new Array();
QuesyionTypeArray[0]="DivSingleChoiceQuestion";
QuesyionTypeArray[1]="DivMultipleChoice";
QuesyionTypeArray[2]="DivFillingBlanks";
QuesyionTypeArray[3]="DivAskAndAnswer";

function QuestionTypeSwitch(obj)
{
for(i=0; i <QuesyionTypeArray.length; i++) 
{ 
document.getElementById(QuesyionTypeArray[i]).style.display="none"; 
}  
if(QuesyionTypeArray[obj.selectedIndex]=="DivFillingBlanks")
{
document.getElementById("bntInsertBlank").style.display="block";
}
else
{
document.getElementById("bntInsertBlank").style.display="none";
}
   
document.getElementById(QuesyionTypeArray[obj.selectedIndex]).style.display="block";   
}*/
//=========================================================================================================

//**********************************code by ganxiaotu****************************************//
var QuesyionTypeArray = new Array();

QuesyionTypeArray[0] = "dan";
QuesyionTypeArray[1] = "duo";
QuesyionTypeArray[2] = "wen";
QuesyionTypeArray[3] = "fu";

function QuestionTypeSwitch(obj) {

    $("div.dan:visible").css("display", "none");
    $("div.duo:visible").css("display", "none");
    $("div.wen:visible").css("display", "none");
    $("div.ziti:visible").css("display", "none");



    if (QuesyionTypeArray[obj.selectedIndex] == "dan") {

        $("div.dan:hidden").slideDown("slow");
    }
    else if (QuesyionTypeArray[obj.selectedIndex] == "duo") {

        $("div.duo:hidden").slideDown("slow");
    }

    else if (QuesyionTypeArray[obj.selectedIndex] == "wen") {
        $("div.wen:hidden").slideDown("slow");
    }
    else if (QuesyionTypeArray[obj.selectedIndex] == "fu") {
        //el("addchildTi").style.display="inline";
        $("div.ziti:hidden").slideDown("slow");
    }
}

function DimensionTypeSwitch(obj, id) {
    $("tr." + id + ":visible").css("display", "none");

    if (obj.selectedIndex == 1) {
        $("tr." + id + ":hidden").css("display", "inline");
    }



}

function DimensionTypeSwitch1(obj, id) {
    $("#" + id).attr("disabled", true);

    if (obj.selectedIndex == 1) {
        $("#" + id).attr("disabled", false);
    }



}


function doCheckInfo() {
    var len = en("c1").length;
    for (i = 0; i < len; i++) {
        if (en("c1")[i].checked) {
            el("fi1").style.border = "1px solid";
            el("fo1").color = "#30598C";
            doNextTi('div2');
            return true;
        }
    }
    el("fi1").style.border = "1px solid red";

    el("fo1").color = "Red";
    alert("题一未答")
    return false;

}



function doXuanMatch(obj, name) {

    if (name == "match") {
        if (match[1].checked) {
            $("span.xuan:visible").css("display", "none");
        }
        else {
            $("span.xuan:hidden").css("display", "inline");
        }
    }
    else {
        if (match1[1].checked) {
            $("span.xuan1:visible").css("display", "none");
        }
        else {
            $("span.xuan1:hidden").css("display", "inline");
        }
    }


}



function QuestionTypeSwitchforchild(obj) {

    $("div.dan:visible").css("display", "none");
    $("div.duo:visible").css("display", "none");
    $("div.wen:visible").css("display", "none");


    if (QuesyionTypeArray[obj.selectedIndex] == "dan") {

        $("div.dan:hidden").slideDown("slow");
    }
    else if (QuesyionTypeArray[obj.selectedIndex] == "duo") {

        $("div.duo:hidden").slideDown("slow");
    }

    // else if(QuesyionTypeArray[obj.selectedIndex]=="wen"){
    // $("div.wen:hidden").slideDown("slow");
    // }  
    else if (QuesyionTypeArray[obj.selectedIndex] == "fu") {
        el("addchildTi").style.display = "inline";
    }
}


function QuestionTypeSwitchTem(obj1, obj2) {
    var str1 = "div." + obj2 + ":hidden";
    var str2 = "div." + obj2 + ":visible";



    if (obj1.checked == true) {
        $(str1).slideDown("slow");

    }
    else {
        $(str2).slideUp("slow");
    }
}



function ShowDialog(url, iWidth, iHeight) {
    //  var iWidth=800; //窗口宽度
    // var iHeight=400;//窗口高度
    var iTop = (window.screen.height - iHeight) / 2;
    var iLeft = (window.screen.width - iWidth) / 2;
    window.showModalDialog(url, window, "dialogHeight: " + iHeight + "px; dialogWidth: " + iWidth + "px;dialogTop: " + iTop + "; dialogLeft: " + iLeft + "; resizable: no; status: no;scroll:yes");
}

function ShowOpen(url, iWidth, iHeight) {
    //  var iWidth=800; //窗口宽度
    // var iHeight=400;//窗口高度
    var iTop = (window.screen.height - iHeight) / 2;
    var iLeft = (window.screen.width - iWidth) / 2;
    window.open(url, "newwindow", "height=" + iHeight + ", width=" + iWidth + ", toolbar= no, menubar=no, scrollbars=no, resizable=no, location=no, status=no,top=" + iTop + ",left=" + iLeft + "")

}


function DoInclude() {
    var str = "<table cellpadding='0' cellspacing='0' width='100%' border='0px'>";
    str += "<tr>";
    str += "<td colspan='6'>";
    str += "<table width='100%'   border='0' cellpadding='0' cellspacing='0'>";
    str += "<tr valign='middle'>";
    str += "<td align='right'  style='height: 24px; width: 72%;'>";
    str += "&nbsp;&nbsp;共<span class='STYLE1'><span id='lblRecordCount' style='color: Red;'>101</span></span>条记录";
    str += "共<font color='red'><span id='LbPageCount'>3</span></font> 页 第 <font color='red'><span id='LbPageIndex'>1</span></font> 页";
    str += "</td>";
    str += "<td align='right'  style='height: 24px'>";
    str += "<a id='BtnFirst' class='myLink_1'  href='#'>首页</a> <a id='BtnPrevious'   href='#' class='myLink_1'>上一页</a> <a class='myLink_1' href='#'></a><a id='BtnNext'class='myLink_1' href='javascript:__doPostBack('BtnNext','')'>下一页</a>";
    str += "<a id='BtnLast' class='myLink_1' href='javascript:__doPostBack('BtnLast','')'>尾页</a>";
    str += "跳转到:<input name='TbPageNum' type='text' id='TbPageNum' class='form1' style='border-right: #bfbfbf 1px solid;border-top: #bfbfbf 1px solid; border-left: #bfbfbf 1px solid; width: 20px; border-bottom: #bfbfbf 1px solid;height: 16px' />页&nbsp;&nbsp;<input type='submit' name='BtnGo' value='GO' id='BtnGo' class='two_button_w' />";
    str += "</td>";
    str += "</tr>";
    str += "</table>  ";
    str += "</td>";
    str += "</tr>";
    str += "</table>";

    document.write(str);


}


function DoInclude1() {
    //var str="<table cellpadding='0' cellspacing='0' width='100%' border='0px'  style='float:right;'>";
    // str+="<tr>";
    // str+="<td colspan='6'>";
    var str = "<table width='100%'   border='0' cellpadding='0' cellspacing='0' style='float:right;'>";
    str += "<tr valign='middle' align='right'>";
    str += "<td align='right'>";
    str += "&nbsp;&nbsp;共<span class='STYLE1'><span id='lblRecordCount' style='color: Red;'>101</span></span>条记录";
    str += "共<font color='red'><span id='LbPageCount'>3</span></font> 页 第 <font color='red'><span id='LbPageIndex'>1</span></font> 页";
    // str+="</td>";
    // str+="<td align='right'  >";
    str += "<a id='BtnFirst' class='myLink_1'  href='#'>首页</a> <a id='BtnPrevious'   href='#' class='myLink_1'>上一页</a> <a class='myLink_1' href='#'></a><a id='BtnNext'class='myLink_1' href='javascript:__doPostBack('BtnNext','')'>下一页</a>";
    str += "<a id='BtnLast' class='myLink_1' href='javascript:__doPostBack('BtnLast','')'>尾页</a>";
    str += "跳转到:<input name='TbPageNum' type='text' id='TbPageNum' class='form1' style='border-right: #bfbfbf 1px solid;border-top: #bfbfbf 1px solid; border-left: #bfbfbf 1px solid; width: 20px; border-bottom: #bfbfbf 1px solid;height: 16px' />页&nbsp;&nbsp;<input type='submit' name='BtnGo' value='GO' id='BtnGo' class='two_button_w' />";
    str += "</td>";
    str += "</tr>";
    str += "</table>  ";
    // str+="</td>";
    //str+="</tr>";
    //str+="</table>";

    document.write(str);
}

function LoadItems(elementID) {
    if (elementID != null) {
        if (document.getElementById(elementID).style.display == "none") {
            document.getElementById(elementID).style.display = "block";

        }
        else document.getElementById(elementID).style.display = "none";

        return;
    }
}

function doTagSwitch(className1, className2) {

    var obj1 = "tr." + className1 + ":hidden";
    var obj2 = "tr." + className2 + ":visible";
    $(obj1).css("display", "inline");
    $(obj2).css("display", "none");

}

function doNextTi(idd) {
    var obj = "div." + idd + ":hidden";
    $("div.div1:visible").css("display", "none");
    $("div.div2:visible").css("display", "none");
    $("div.div3:visible").css("display", "none");
    $(obj).slideDown("slow");


}



function doCopyRight() {
    var str = "<div id='Bom1' style='text-align: center;' class='divFooter' style='height: 26px; width: 100%;'><p>版权所有 &copy; 2007 辉瑞健康咨询（上海）有限公司. 保留所有权利. <span><a id='ctl00_lnkCopyRight'>版权信息</a> |<a id='ctl00_lnkPrivacyPolicy'>隐私权政策</a></span></p></div>";
    document.write(str);
}





//全屏显示Web页面
//Url  Web页面地址
function MachakFull(Url) {

    if (Url == "" || Url == null) {
        return;
    }
    //    x = screen.availWidth;
    //    y = screen.availHeight;
    //    target = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf(".") - 1, navigator.appVersion.length));
    //    if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1) && (parseInt(navigator.appVersion) == 4))
    //        window.open(other, "sub", "scrollbars=yes", "toolbar=no");

    //    try {
    //        if (target >= 4) {

    //            if (navigator.appName == "Netscape") {
    //                var MachakFull = window.open(Url, "MachakFull", "scrollbars=yes", "toolbar=no", "width=" + x + ",height=" + y + ",top=0,left=0");
    //                MachakFull.moveTo(0, 0);
    //                MachakFull.resizeTo(x, y);
    //            }
    //            if (navigator.appName == "Microsoft Internet Explorer")
    //                window.open(Url, "MachakFull", "fullscreen=yes", "toolbar=no", "resizable=no,scrollbars=no");
    //        }
    //        else window.open(Url, "sub", "scrollbars=yes", "toolbar=no");
    //    }
    //    catch (Exception) {
    //        return false;
    //    }
    window.open(Url, "MachakFull", "fullscreen,scrollbars,resizable=yes");
    return false;
}



//全屏显示Web页面
//Url  Web页面地址
function MachakFullQ(Url) {

    if (Url == "" || Url == null)
        return;
    x = screen.availWidth;
    y = screen.availHeight;
    target = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf(".") - 1, navigator.appVersion.length));
    if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1) && (parseInt(navigator.appVersion) == 4))
        window.open(other, "sub", "scrollbars=yes", "toolbar=no");

    try {
        if (target >= 4) {

            if (navigator.appName == "Netscape") {
                var MachakFull = window.open(Url, "MachakFull", "scrollbars=yes", "toolbar=no", "width=" + x + ",height=" + y + ",top=0,left=0");
                MachakFull.moveTo(0, 0);
                MachakFull.resizeTo(x, y);
            }
            if (navigator.appName == "Microsoft Internet Explorer")
                window.open(Url, "MachakFull", "fullscreen=yes", "toolbar=no", "resizable=no,scrollbars=no");
        }
        else window.open(Url, "sub", "scrollbars=yes", "toolbar=no");
    }
    catch (Exception) {
        return
    }
    //closes.Click()
}


function doConfirm() {
    var flag = window.confirm('是否进入热身题测试,点击是进入测试，否直接进入考试');

    if (flag == true) {

        MachakFullQ('WarmUpTest.htm');
    }
    else {
        MachakFullQ('ExamContentTest.htm');
    }

}


var flag = "edit";
function doEdit(id, id1) {

    if (flag == "edit") {
        el(id).innerHTML = "<input type='text'  id='txt1'  style='width:25px;height:15px;' />";
        el(id1).value = "保存";
        flag = "save";
    }
    else {
        el(id).innerHTML = el("txt1").value;
        el(id1).value = "编辑";

        flag = "edit";

    }



}




function doInsertRow() {
    var len = parseInt(el("Psection").value) + 1;
    el("Psection").value = len;
    var mytable = el("section");
    var rowlen = mytable.rows.length;
    var newRow = mytable.insertRow(rowlen);
    newRow.id = "rowSection_" + len;
    var newtd1 = newRow.insertCell(0);
    newtd1.innerText = "Section" + len;
    var newtd2 = newRow.insertCell(1);
    newtd2.innerHTML = "<input id='Section" + len + "txt' type='text' />"
    var newtd3 = newRow.insertCell(2);
    newtd3.innerHTML = "<input class='bigBtn'  id='SectionAdd" + len + "btn'  type='button' value='添加' />"
    var newtd4 = newRow.insertCell(3);
    newtd4.innerHTML = "<input class='bigBtn'  id='SectionDel" + len + "btn'  type='button' value='删除' />"
    var newtd5 = newRow.insertCell(4);
    newtd5.innerHTML = "<input class='bigBtn'  id='SectionAddTi" + len + "btn'  type='button' value='添加试题' />"

}

function doDelRow(obj) {

    var mytable = el("section");
    var rowid = obj.parentNode.parentNode.id

    var num = parseInt(obj.parentNode.parentNode.id.split("_")[1]);
    var len = parseInt(el("Psection").value) - num;


    mytable.deleteRow(rowid);

    for (i = 0; i < len; i++) {

        num += 1;
        var nextSection = "rowSection_" + num;
        el(nextSection).id = rowid;
        rowid = nextSection;
        var mylist = document.getElementById(nextSection)
        alert(mylist.childNodes.length)
        //el(nextSection).childNode.intText="Section"+num-1;



    }

    //alert(obj.parentNode.parentNode.nextNode.id)
}
//trim null
function Trim(m) {
    while ((m.length > 0) && (m.charAt(0) == ' '))
        m = m.substring(1, m.length);
    while ((m.length > 0) && (m.charAt(m.length - 1) == ' '))
        m = m.substring(0, m.length - 1);
    return m;
}
function IsNumber(value, errMsg) {
    if (!isNaN(value)) {
        alert(errMsg);
        return false;
    }

    return true;
}